import { Viewer, Entity, ScreenSpaceEventHandler } from "cesium";
import BaseLoader from "../base"
import { ICesiumLoader } from "@/types/loader";
import ImagePlotting from "@/cesium/plotting";
import { useCesiumGlobalStore } from "@/store/modules/cesiun-global"


type PlottingOptions = {
    name: string;
    imgSrc: string;
    handler: ScreenSpaceEventHandler;
}
export default class drawPoint extends BaseLoader implements ICesiumLoader {
    viewer: Viewer;
    entity: Entity;
    loader: ImagePlotting;
    imgSrc: string = '';
    handler: ScreenSpaceEventHandler | null = null
    constructor(viewer: Viewer, options?: Omit<PlottingOptions, 'handler'>) {
        super(viewer);
        this.viewer = viewer;
        this.handler = new ScreenSpaceEventHandler(this.viewer.scene.canvas);
        this.init(viewer, {
            ...options,
            handler: this.handler
        });
    }

    init(viewer: Viewer, options?: PlottingOptions): void {
        this.loader = new ImagePlotting(viewer, options);
        this.loader.initEvents()
    }


    getData(): Record<string, any> {
        throw new Error('Method not implemented.');
    }

    getEntity(): Entity | void {
        throw new Error('Method not implemented.');
    }

    remove(): boolean {
        throw new Error('Method not implemented.');
    }

    destroy(): void {
        this.loader.destroy()
        super.removeEscEvent()
        useCesiumGlobalStore().loader = null
    }
}